﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    schema="dbo"
    assembly="Simnova.Collaborate.ServiceContract"
    namespace="Simnova.Collaborate.ServiceContract.DataClasses"
    >
	<class
       name="Feedback"
       table="feedback"
       lazy="false"
     >
		<id
           name="feedbackId"
           type="Int32"
           column="feedbackId"
           unsaved-value="0"
           access="field">
			<generator class="identity" />
		</id>
		<property
            name="productId"
            column="productId"
            access="field"
            />
		<property
            name="userId"
            column="userId"
            access="field"
            />
		<property
			name="averageRating"
			formula="(SELECT avg(fr.rating) FROM feedbackRating fr WHERE fr.feedbackId = feedbackId)"
            access="field"
			insert="false"
			update="false"
			/>
		<property
			name="ratings"
			formula="(SELECT count(fr.feedbackId) FROM feedbackRating fr WHERE fr.feedbackId = feedbackId)"
            access="field"
			insert="false"
			update="false"
			/>
		<property
			name="workarounds"
            access="field"
			formula="(SELECT count(fw.feedbackId) FROM feedbackWorkaround fw WHERE fw.feedbackId = feedbackId)"
			insert="false"
			update="false"
			/>
		<property
            name="title"
            column="title"
            access="field"
            />
		<property
            name="description"
            column="description"
            access="field"
            />
		<property
            name="createDate"
            column="createDate"
            access="field"
			insert="false"
			update="false"
            />
	</class>
</hibernate-mapping>